package com.camel.base.ei;

/**
 * HTTP结果封装
 *
 * @author yanxiaoneng
 * @date 2019/07/15
 */
public class HttpResult {

    public static final String SC_INTERNAL_SERVER_CODE_BUSINESS_ERROR = "700";
    public static final String SC_INTERNAL_SERVER_CODE_SYS_ERROR = "500";
    public static final String SC_INTERNAL_SERVER_CODE_BUSINESS_SUCCESS = "200";
    public static final String AISUCCESS = "0";

    private String code = SC_INTERNAL_SERVER_CODE_BUSINESS_SUCCESS;
    private String msg;
    private Object data;

    public HttpResult() {
    }

    public HttpResult(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static HttpResult error() {
        return error(SC_INTERNAL_SERVER_CODE_SYS_ERROR, "未知异常，请联系管理员");
    }

    public static HttpResult error(String msg) {
        return error(SC_INTERNAL_SERVER_CODE_BUSINESS_ERROR, msg);
    }

    public static HttpResult error(String code, String msg) {
        HttpResult r = new HttpResult();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }

    public static HttpResult ok(String msg) {
        HttpResult r = new HttpResult();
        r.setCode(SC_INTERNAL_SERVER_CODE_BUSINESS_SUCCESS);
        r.setMsg(msg);
        return r;
    }

    public static HttpResult ok(String msg, Object data) {
        HttpResult r = new HttpResult();
        r.setCode(SC_INTERNAL_SERVER_CODE_BUSINESS_SUCCESS);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public static HttpResult ok(Object data) {
        HttpResult r = new HttpResult();
        r.setCode(SC_INTERNAL_SERVER_CODE_BUSINESS_SUCCESS);
        r.setData(data);
        return r;
    }

    public static HttpResult ok() {
        HttpResult r = new HttpResult();
        r.setCode(SC_INTERNAL_SERVER_CODE_BUSINESS_SUCCESS);
        return r;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
